package ar.uba.fi.RSACryptoFiuba.view.commons;

import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder;
import javax.swing.border.TitledBorder;

@SuppressWarnings("serial")
public class ResultsPanel extends javax.swing.JPanel {
                 
    private JPanel resultsPanel;        
    private JLabel firstLabel;
    private JLabel secondLabel;
    private JTextField firstValue;
    private JTextField secondValue;
    	
    public ResultsPanel() {
        initComponents();
    }
                          
    private void initComponents() {

        firstLabel = new JLabel();
        secondLabel = new JLabel();

        resultsPanel = new JPanel();
        resultsPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        resultsPanel.setToolTipText("");

        firstLabel.setFont(new Font("Ubuntu", 1, 18));
        firstLabel.setHorizontalAlignment(SwingConstants.CENTER);

        secondLabel.setFont(new Font("Ubuntu", 1, 18));
        secondLabel.setHorizontalAlignment(SwingConstants.CENTER);
        
        JPanel framePanel = new JPanel();
        framePanel.setBorder(BorderFactory.createTitledBorder(null, "Resultados", TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION));
        
        firstValue = new JTextField();
        firstValue.setBackground(getBackground());
        firstValue.setHorizontalAlignment(JTextField.CENTER);
        firstValue.setBorder(BorderFactory.createEmptyBorder());
        firstValue.addKeyListener(new NavigableKeyActionListener());

        secondValue = new JTextField();
        secondValue.setBackground(getBackground());
        secondValue.setHorizontalAlignment(JTextField.CENTER);
        secondValue.setBorder(BorderFactory.createEmptyBorder());
        secondValue.addKeyListener(new NavigableKeyActionListener());
        
        GroupLayout framePanelLayout = new GroupLayout(framePanel);
        framePanel.setLayout(framePanelLayout);
        framePanelLayout.setHorizontalGroup(
            framePanelLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(framePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(framePanelLayout.createParallelGroup(Alignment.LEADING)
                    .addComponent(firstLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(firstValue)
                    .addComponent(secondLabel, GroupLayout.DEFAULT_SIZE, 619, Short.MAX_VALUE)
                    .addComponent(secondValue, Alignment.TRAILING))
                .addContainerGap())
        );
        framePanelLayout.setVerticalGroup(
            framePanelLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(framePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(firstLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(ComponentPlacement.UNRELATED)
                .addComponent(firstValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(secondLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(secondValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        GroupLayout layout = new GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(framePanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(framePanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addGap(0, 19, Short.MAX_VALUE))
        );
    }
	
	public void setResultsValues(String firtLabel, String secondLabel, String firtValue, String secondValue) {
		this.firstLabel.setText(firtLabel);
        this.secondLabel.setText(secondLabel);
        
        this.firstValue.setText(firtValue);
        this.secondValue.setText(secondValue);
	}
}
